package com.xuan.config;

import com.xuan.constant.MQConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MQConfig {


    @Bean
    public Queue sendSmsQueue(){
        return new Queue(MQConstant.SEND_SMS_QUEUE_NAME,true,false,false);
    }

   @Bean
    public DirectExchange sendSmsExchange(){
        return new DirectExchange(MQConstant.SEND_SMS_DIRECT_EXCHANGE,true,false);
   }

   @Bean
    public Binding bindingSendSms(){
        return BindingBuilder.bind(sendSmsQueue()).to(sendSmsExchange()).with(MQConstant.SEND_SMS_KEY_BINDING);
   }
}
